package com.cyh.pangu.offer;

import java.util.HashMap;
import java.util.Map;

public class Offer57 {

    public int[] twoSum(int[] nums, int target) {
        int[] result = new int[2];
        int i = 0, j = nums.length -1;
        while (i<=j) {
            if (nums[i] + nums[j] < target) {
                i++;
            } else if (nums[i] + nums[j] > target) {
                j--;
            } else {
                result[0] = nums[i];
                result[1] = nums[j];
                return result;
            }
        }
        return new int[0];
    }

    public static void main(String[] args) {
        int[] nums = null;
        int target = 10;
        Offer57 offer57 = new Offer57();
        int[] result = offer57.twoSum(nums, target);
        for (int i : result) {
            System.out.println("i:" + i);
        }
    }
}
